Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/847 allow caching multi arch builds #1467

Conversation

coretechsec
Copy link
Contributor

Updated handling of c/c++ build commands with multiple -arch flags in response to #847.

Testing has predominantly been done on macOS.

harryt@coretechsec added 14 commits December 12, 2022 10:36
Added a new member to the parsed arguments struct to store the architecture related arguments.
Instead of raising a cannot cache error, store the arch arguments in their own vector.
Pass arch args to parsedArguments initialisation
Rewrite the arch args for use in the preprocessor command. This is done to reflect the architectures being used while not causing clang to error due to multiple architectures being specified.
Fixed naming of unused variable from match
Include the architecture arguments when generating the hash key.
Without this, commands that are identical apart from the architecture will be treated as the same.
Updated tests to make sure to initialise parsedArguments with the new arch args vector.
Make sure to include the arch args in the command used for compilation.
Updated test in clang.rs so that it no longer expects a cannot_cache result to be returned.
Updated gcc test that expected a cannot_cache result when multiple arguments are provided.
Added a unit test to make sure arch args get rewritten correctly.
Use string formatting and iter rather than push and a loop
Use vector extend rather than a for loop.
Increase cache version to reflect change in what is used to generate the hash key.
@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2022

Codecov Report

Base: 29.85% // Head: 30.02% // Increases project coverage by +0.16% 🎉

Coverage data is based on head (5dbe435) compared to base (8e0d07d).
Patch coverage: 46.26% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1467      +/-   ##
==========================================
+ Coverage   29.85%   30.02%   +0.16%     
==========================================
  Files          47       47              
  Lines       16974    16642     -332     
  Branches     8056     7870     -186     
==========================================
- Hits         5068     4997      -71     
+ Misses       6504     6336     -168     
+ Partials     5402     5309      -93     
Impacted Files Coverage Δ
src/compiler/c.rs 38.26% <0.00%> (-0.73%) ⬇️
src/compiler/diab.rs 47.05% <0.00%> (-0.26%) ⬇️
src/compiler/msvc.rs 43.42% <0.00%> (-0.10%) ⬇️
src/compiler/tasking_vx.rs 43.68% <0.00%> (-0.25%) ⬇️
src/compiler/gcc.rs 55.26% <53.70%> (+0.01%) ⬆️
src/compiler/clang.rs 53.36% <100.00%> (+0.44%) ⬆️
src/cmdline.rs 24.40% <0.00%> (-4.66%) ⬇️
src/jobserver.rs 47.91% <0.00%> (-2.09%) ⬇️
src/util.rs 34.41% <0.00%> (-1.21%) ⬇️
src/config.rs 35.81% <0.00%> (-0.75%) ⬇️
... and 14 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sylvestre
Copy link
Collaborator

I guess you saw the clippy warning

harryt@coretechsec added 2 commits December 13, 2022 18:16
Formatted code with rustfmt
Refactored match statement into map as per clippy hint.
@coretechsec
Copy link
Contributor Author

I guess you saw the clippy warning

Yeah, thanks. I think I've fixed it now

@sylvestre
Copy link
Collaborator

It looks great. could you please update the doc with this info ?
https://github.com/mozilla/sccache/blob/main/docs/Caching.md

Updated the docs on caching to reflect the updated hash key generation.
@coretechsec
Copy link
Contributor Author

It looks great. could you please update the doc with this info ? https://github.com/mozilla/sccache/blob/main/docs/Caching.md

Updated now. Hopefully its clear enough as is but happy to tweak it.

@sylvestre
Copy link
Collaborator

This is great, thanks

@sylvestre sylvestre merged commit 635b2a1 into mozilla:main Dec 15, 2022
@coretechsec coretechsec deleted the feature/847-allow-caching-multi-arch-builds branch December 15, 2022 10:17
@alcroito
Copy link

Latest 0.4.1 which includes this PR breaks multi-arch compilation that uses -Xarch flags.

#847 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants